<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
  <title><spring:message code="activiti.task.handle.title" /></title>
  <meta name="decorator" content="grid-select"/>
  <html:css  name="iCheck,Validform,jquery-ztree,amaze-ui"/>
  <link type="text/css" rel="stylesheet" href="${staticPath}/modules/activiti/css/style.css">
  <html:js  name="iCheck,Validform,jquery-ztree,jquery"/>
  <script type="text/javascript" src="${staticPath}/modules/activiti/js/workflow.js"></script>
  <script type="text/javascript" src="${staticPath}/common/js/window.js"></script>
</head>
<body title="<spring:message code="activiti.task.handle.title" />">
	<input id="nextAuditor" name="nextAuditor" type="hidden"> 
    	<div id="flow-audit">
			<div class="panel tools">
				<button type="button" onclick="audite()" class="am-btn am-btn-success"><i class="am-icon-gavel"></i>审批</button>
				<button type="button" onclick="transferTask('${adminPath}',${param.taskId},callBack)" class="am-btn am-btn-primary"><i class="am-icon-undo"></i>转办</button>	
				<%-- <button type="button" onclick="backProcessTask('${adminPath}',${param.taskId})" class="am-btn am-btn-danger"><i class="am-icon-reply-all"></i>驳回</button> --%>
				<%-- <button type="button" onclick="jumpTaskFlow('${adminPath}',${param.taskId})" class="am-btn am-btn-primary"><i class="am-icon-reply-all"></i>跳转</button> --%>
				<%-- <button type="button" onclick="joinPassTask('${adminPath}',${param.taskId})" class="am-btn am-btn-success"><i class="am-icon-edit"></i>会签</button> --%>
				<%-- <button type="button" onclick="nextAuditor('${adminPath}',${param.taskId})" class="am-btn am-btn-primary"><i class="am-icon-share-square-o"></i>下一步参与人</button> --%>	
				<%-- <button type="button" onclick="showAuditeInfo('${adminPath}',${param.taskId})" class="am-btn am-btn-danger"><i class="am-icon-twitch"></i>审批信息</button> --%>
				<button type="button" onclick="showBillInfo('${formUrl}')" class="am-btn am-btn-primary"><i class="am-icon-search"></i>查看单据</button>	
				<button type="button" onclick="showflow('${adminPath}',${param.taskId})" class="am-btn am-btn-danger"><i class="am-icon-object-group"></i>流程图</button>
			</div>
			<div class="panel top">
				<iframe src="${formUrl}" width="100%" height="100%" onload="ifrloadFun(this)"></iframe>
			</div>
			<div class="panel f-left">
				<div class="manage">
					<div class="t">审核处理</div>
					<input type="radio" name="policy" id="policy" value="0" onclick="changeOpinion(this.value)" checked="checked"/>同意
					<input type="radio" name="policy" id="policy" value="1" onclick="changeOpinion(this.value)"/>不同意
				</div>
				<div class="idea">
					<div class="t">审核意见</div>
					<textarea id="opinion" name="opinion" style="min-height: 80px">审批通过</textarea>
				</div>
			</div>
			<div class="panel f-right" style="width: 100%">
				<grid:grid id="activitiModelId" sortname="t.start_time_" url="${adminPath}/activiti/flow/history/histaskComment?taskId=${param.taskId}"
						multiselect="false" scrollpage="true">
					<grid:column label="activiti.task.id" hidden="true"   name="id" width="100"/>
					<grid:column label="activiti.task.activiti.name"  name="name" />
				    <grid:column label="activiti.task.assignee"  name="assigneeName"/>
				    <grid:column label="activiti.task.history.message"  name="message"/>
				    <grid:column label="activiti.task.starttime"  name="startTime" />
				    <grid:column label="activiti.task.history.endtime"  name="endTime" />
				    <grid:column label="activiti.task.history.duration"  name="duration" />
				    <grid:column label="activiti.task.history.attachname"  name="attachName"  />
				</grid:grid>
			</div>
		</div>
		
<script type="text/javascript">
	function ifrloadFun(ifr){
		//var ifr = th.find('iframe')[0];
        /*禁止输入&点击*/
        /* var input = ifr.contentDocument.getElementsByTagName("input");
        var btn = ifr.contentDocument.getElementsByClassName("btn");
        var tara = ifr.contentDocument.getElementsByTagName("textarea");
        var select = ifr.contentDocument.getElementsByTagName("select");
        var btnDate = ifr.contentDocument.getElementsByClassName("layer-date");
        $(input).attr("readonly","readonly");
        $(tara).attr("readonly","readonly");
        $(select).attr("disabled","disabled");
        $(btnDate).prop("onclick",null).off("click"); */
        /*查看状态是，禁止删除附件*/
        setTimeout(function(){
            var rb = ifr.contentDocument.getElementsByClassName("kv-file-remove");
            $(rb).hide();
            /*启用查看和下载功能按钮*/
            var zoom = ifr.contentDocument.getElementsByClassName("kv-file-zoom"),
            	down = ifr.contentDocument.getElementsByClassName(" kv-file-down");
            	file = ifr.contentDocument.getElementsByClassName(" btn-file");
            $(zoom).removeAttr("disabled");
            $(down).removeAttr("disabled");
            $(file).hide();
        },500);
	}
	$(function(){
		$("#flow-audit > div.panel.f-right > div > div").remove(".row");
	});

	/**
	 * @discription rediogroups点击事件，修改审批意见的内容.<br>
	 * @author zcg .<br>
	 * @date 2017/12/26 .<br>
	 */
	function changeOpinion(value){
		if(value==1){
			$('#opinion').val('打回修改');
		}else{
			$('#opinion').val('审批通过');
		}
	}

	/**
	 * @discription 审批任务.<br>
	 * @author zcg .<br>
	 * @date 2017/12/15 .<br>
	 */
	function audite(){
		var basePath = '${adminPath}';
		var taskId = '${param.taskId}';
		var nextAuditor = $('#nextAuditor').val();
		var policy = $("input[name='policy']:checked").val();
		var opinion = $('#opinion').val();
		var isAllowHit = '${isAllowHit}';
		if(policy==1&&isAllowHit=='false'){
			layer.alert('节点未配置打回路径，不允许执行改操作', {
				icon: 5,
				title: "温馨提示"
			});
		}else{
			//询问框
			layer.confirm('您确定要执行该操作吗？', {
				title: "温馨提示",
			  	btn: ['确定','放弃'] //按钮
			}, function(){
				auditeBill(basePath,taskId,nextAuditor,policy,opinion,callBack);
			});
		}
	}
	
	 /**
	  * @discription 操作成功之后回调.<br>
	  * @author zcg .<br>
	  * @date 2017/12/15 .<br>
	  */
	function callBack(result){
		 if(result.ret==0){ 
       	    top.layer.msg(result.msg, {icon: 1});
       	 	setTimeout(function(){top.layer.closeAll()}, 200);
		 }else{
			top.layer.msg(result.msg, {icon: 2});
		 }
	 }

</script>
<script type="text/javascript">
	(function(){
		function panelInit(){
			var winHeight = window.innerHeight;
			var panelTop = document.getElementsByClassName("top")[0];
			var panelLeft = document.getElementsByClassName("f-left")[0];
			var panelRight = document.getElementsByClassName("f-right")[0];
			
			panelTop.style.cssText = "height:"+(winHeight*0.7-50)+"px;top:50px";
			panelLeft.style.cssText = "height:"+winHeight*0.3+"px;top:"+winHeight*0.7+"px";
			panelRight.style.cssText = "height:"+winHeight*0.3+"px;top:"+winHeight*0.7+"px;left:30%";
			
			panelRight.getElementsByTagName("iframe")[0].style.height = winHeight*0.3+"px";
		}
		panelInit();
		window.onresize = panelInit;
	})();
</script>
</body>
</html>